
**TABLE 7 : Repayment Outcomes**

**BEFORE LOAN LOTTERY**

use "$data\admin_data", clear

********
*Initial data steps
	rename d_uptake_during_after_LL_new_8 d_f
	gen EDT_elig=(EDT_treat==1 & d_lleligible==1)
	gen EDT_no_elig=(EDT_treat==1 & d_lleligible==0)
	gen nobt_ne = EDT_treat==0 & d_lleligible==0
	gen EDT_elig_fem=EDT_elig*female
	gen EDT_no_elig_fem=EDT_no_elig*female
	gen nobt_ne_fem=nobt_ne*female

********
*Column (1): Took loan
est clear
local j =1
foreach y of varlist d_uptake_before_LL_new  {
	reg `y' EDT_treat bl_bus_owner female d_lleligible fu_dummy* if fu_dummy7 ==0 , cl(co_code1)
	estimates store `y'
	sum `y' if   fu_dummy7 ==0
	sum `y' if  fu_dummy7 ==0 & EDT_treat==0 
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}	
estout * using "$out/Table7A-col1.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) stats(mean_y N r2, fmt(2 0 2) ///
	labels("mean dependent variable" "N.obs" "R-Sq")) replace

est clear
local j =1
foreach y of varlist d_uptake_before_LL_new  {
	reg `y' EDT_elig EDT_no_elig nobt_ne bl_bus_owner female fu_dummy* if  fu_dummy7 ==0 , cl(co_code1)
	estimates store `y'
	sum `y' if   fu_dummy7 ==0
	sum `y' if  fu_dummy7 ==0 & EDT_treat==0 & d_lleligible==1
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}
estout * using "$out/Table7C-col1.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) stats(mean_y N r2, fmt(2 0 2) ///
	labels("mean dependent variable" "N.obs" "R-Sq")) replace
estimates clear

*Amount of the Loan, Female Interaction*
est clear
local j =1
foreach y of varlist  d_uptake_before_LL_new {
	reg `y' EDT_treat EDT_female d_lleligible female bl_bus_owner fu_dummy* if  fu_dummy7 ==0, cl(co_code1)
	estimates store `y'
	test EDT_treat + EDT_female=0
	estadd scalar p_diff1 = r(p)		
	sum `y' if   fu_dummy7 ==0
	sum `y' if  fu_dummy7 ==0 & EDT_treat==0 & female==0
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}	
estout * using "$out/Table7B-col1.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) stats(mean_y N r2 p_diff1, fmt(%9.2f %9.0f %9.2f %9.2f) ///
	labels("mean dependent variable" "N.obs" "R-Sq" "P_vals1")) replace

est clear
local j =1
foreach y of varlist  d_uptake_before_LL_new {
	reg `y' female EDT_elig EDT_elig_fem EDT_no_elig EDT_no_elig_fem ///
		nobt_ne nobt_ne_fem bl_bus_owner fu_dummy* if  fu_dummy7 ==0, cl(co_code1)
	estimates store `y'
	test EDT_elig + EDT_elig_fem=0
	estadd scalar p_diff1 = r(p)		
	test EDT_no_elig + EDT_no_elig_fem=0
	estadd scalar p_diff2 = r(p)
	test nobt_ne + nobt_ne_fem=0
	estadd scalar p_diff3 = r(p)		
	sum `y' if   fu_dummy7 ==0
	sum `y' if  fu_dummy7 ==0 & EDT_treat==0 & d_lleligible==1 & female==0
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}
estout * using "$out/Table7D-col1.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) stats(mean_y N r2 p_diff1 p_diff2 p_diff3, fmt(%9.2f %9.0f %9.2f %9.2f) ///
	labels("mean dependent variable" "N.obs" "R-Sq" "P_vals1" "P_vals2" "P_vals3")) replace

********
*Columns (2) - (4)
	*(2) Loan amont (log)
	*(3) Amount due at 20 days (as % of principal)
	*(4) Amount due at maturity (as % of principal)

use "$data/admin_data_loans", clear

*Initial data steps
gen log_amount_new = log_amount
replace log_amount_new = log(1) if log_amount_new == .
ren d_uptake_during_after_LL_new d_f
gen EDT_elig=(EDT_treat==1 & d_lleligible==1)
gen EDT_no_elig=(EDT_treat==1 & d_lleligible==0)
gen nobt_ne = EDT_treat==0 & d_lleligible==0
gen EDT_elig_fem=EDT_elig*female
gen EDT_no_elig_fem=EDT_no_elig*female
gen nobt_ne_fem=nobt_ne*female

est clear
local j =1
foreach y of varlist log_amount_new  at_maturity_20 at_maturity {
	reg `y' EDT_treat bl_bus_owner female d_lleligible fu_dummy* if d_uptake_before_LL_new==1 , cl(co_code1)
	estimates store `y'
	sum `y' if  d_uptake_before_LL_new==1 
	sum `y' if  EDT_treat==0 & d_uptake_before_LL_new==1
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}
estout * using "$out/Table7A-col2-4.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) stats(mean_y N r2, fmt(2 0 2) ///
	labels("mean dependent variable" "N.obs" "R-Sq")) replace
	
est clear
local j =1
foreach y of varlist log_amount_new  at_maturity_20 at_maturity {
	reg `y' EDT_elig EDT_no_elig nobt_ne bl_bus_owner female  fu_dummy* if d_uptake_before_LL_new==1 , cl(co_code1)
	estimates store `y'
	sum `y' if  d_uptake_before_LL_new==1 
	sum `y' if  L_ttreat==0 & EDT_treat==0 & d_uptake_before_LL_new==1 & d_lleligible==1
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}	
estout * using "$out/Table7C-col2-4.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) stats(mean_y N r2, fmt(2 0 2) ///
	labels("mean dependent variable" "N.obs" "R-Sq")) replace

*Amount of the Loan, Female Interaction
est clear
local j =1
foreach y of varlist log_amount_new at_maturity_20 at_maturity  {
	reg `y' EDT_treat EDT_female bl_bus_owner d_lleligible female fu_dummy* if d_uptake_before_LL_new==1 , cl(co_code1)
	estimates store `y'
	test EDT_treat + EDT_female=0
	estadd scalar p_diff1 = r(p)
	sum `y'  if  d_uptake_before_LL_new==1 
	sum `y'  if  EDT_treat==0 & d_uptake_before_LL_new ==1 & female==0
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}	
estout * using "$out/Table7B-col2-4.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) stats(mean_y N r2 p_diff1 , fmt(%9.2f %9.0f %9.2f %9.2f) ///
	labels("mean dependent variable" "N.obs" "R-Sq" "P_vals1")) replace

est clear
local j =1
foreach y of varlist log_amount_new at_maturity_20 at_maturity  {
	reg `y' EDT_elig EDT_elig_fem EDT_no_elig EDT_no_elig_fem nobt_ne ///
	nobt_ne_fem bl_bus_owner  female  fu_dummy* if d_uptake_before_LL_new==1, cl(co_code1)
	estimates store `y'
	test EDT_elig + EDT_elig_fem=0
	estadd scalar p_diff1 = r(p)
	test EDT_no_elig + EDT_no_elig_fem=0
	estadd scalar p_diff2 = r(p)
	test nobt_ne + nobt_ne_fem=0
	estadd scalar p_diff3 = r(p)
	sum `y'  if  d_uptake_before_LL_new==1 
	sum `y'  if L_ttreat==0 & EDT_treat==0 & d_uptake_before_LL_new ==1 & d_lleligible==1 & female==0
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}
estout * using "$out/Table7D-col2-4.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) stats(mean_y N r2 p_diff1 p_diff2 p_diff3, fmt(%9.2f %9.0f %9.2f %9.2f) ///
	labels("mean dependent variable" "N.obs" "R-Sq" "P_vals1" "Pvals2" "Pvals3")) replace


**DURING & AFTER LOAN LOTTERY**

use "$data/admin_data.dta", clear

********
*Initial data steps
	rename d_uptake_during_after_LL_new_8 d_f
	gen A_EDT_elig=(A_EDT==1 & d_lleligible==1)
	gen A_EDT_no_elig=(A_EDT==1 & d_lleligible==0)
	gen nobt_ne_nolw = EDT_treat==0 & d_lleligible==0 & L_ttreat==0
	gen A_EDT_elig_fem=A_EDT_elig*female
	gen A_EDT_no_elig_fem=A_EDT_no_elig*female
	gen nobt_ne_nolw_fem=nobt_ne_nolw*female

********
*Column (5): Took loan
est clear
local j =1
	foreach y of varlist d_f  {
	reg `y' EDT_treat bl_bus_owner female d_lleligible fu_dummy* if  fu_dummy7 ==0, cl(co_code1)
	estimates store `y'	
	sum `y' if  d_f==1
	sum `y' if fu_dummy7 ==0 & EDT_treat == 0
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}
estout * using "$out/Table7A-col5.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(mean_y N r2, fmt(2 0 2 2 2 2 ) ///
	labels("mean dependent variable" "N.obs" "R-Sq")) replace

est clear
local j =1
foreach y of varlist d_f  {
	reg `y' A_EDT_elig A_EDT_no_elig B_LL C_EDT_LL nobt_ne_nolw bl_bus_owner ///
		female fu_dummy* if  fu_dummy7 ==0, cl(co_code1)
	estimates store `y'	
	test A_EDT_elig =B_LL
	estadd scalar p_diff1 = r(p)
	test A_EDT_elig =C_EDT_LL
	estadd scalar p_diff2 = r(p)
	test C_EDT_LL =B_LL
	estadd scalar p_diff3 = r(p)
	test A_EDT_no_elig =nobt_ne_nolw
	estadd scalar p_diff4 = r(p)
	sum `y' if  d_f==1
	sum `y' if fu_dummy7 ==0 & EDT_treat == 0 & L_ttreat ==0 & d_lleligible==1
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}
estout * using "$out/Table7C-col5.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(mean_y N r2 p_diff1 p_diff2 p_diff3 p_diff4, fmt(2 0 2 2 2 2 ) ///
	labels("mean dependent variable" "N.obs" "R-Sq" "p1" "p2" "p3" "p4")) replace

*Loan, Female Interaction
est clear
local j =1
foreach y of varlist     d_f  {
	reg `y' EDT_treat EDT_female bl_bus_owner d_lleligible female fu_dummy* ///
		if fu_dummy7 ==0, cl(co_code1)
	estimates store `y'
	test EDT_treat + EDT_female=0
	estadd scalar p_diff1 = r(p)	
	sum `y' if   fu_dummy7 ==0
	sum `y' if fu_dummy7 ==0 & EDT_treat == 0 & female==0
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}
estout * using "$out/Table7B-col5.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(mean_y N r2 p_diff1, fmt(2 0 2 2 2 2 2 2 2 ) ///
	labels("mean dependent variable" "N.obs" "R-Sq" "p1")) replace

est clear
local j =1
foreach y of varlist d_f  {
	reg `y'  A_EDT_elig A_EDT_elig_fem A_EDT_no_elig A_EDT_no_elig_fem ///
		nobt_ne_nolw  nobt_ne_nolw_fem B_LL B_female C_EDT_LL C_female ///
		bl_bus_owner female fu_dummy* if fu_dummy7 ==0, cl(co_code1)
	estimates store `y'	
	test A_EDT_elig =B_LL
	estadd scalar p_diff1 = r(p)
	test A_EDT_elig =C_EDT_LL
	estadd scalar p_diff2 = r(p)
	test C_EDT_LL =B_LL
	estadd scalar p_diff3 = r(p)
	test A_EDT_no_elig =nobt_ne_nolw
	estadd scalar p_diff4 = r(p)
	test A_EDT_elig + A_EDT_elig_fem=0
	estadd scalar p_diff5 = r(p)
	test A_EDT_no_elig + A_EDT_no_elig_fem=0
	estadd scalar p_diff6 = r(p)
	test nobt_ne_nolw + nobt_ne_nolw_fem=0
	estadd scalar p_diff7= r(p)
	test B_LL +B_female =0
	estadd scalar p_diff8 = r(p)
	test C_EDT_LL +C_female =0
	estadd scalar p_diff9 = r(p)
	sum `y' if   fu_dummy7 ==0
	sum `y' if fu_dummy7 ==0 & EDT_treat == 0 & L_ttreat ==0 & d_lleligible==1 & female==0
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}
estout * using "$out/Table7D-col5.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(mean_y N r2 p_diff1 p_diff2 p_diff3 p_diff4 p_diff5 p_diff6 p_diff7 p_diff8 p_diff9, fmt(2 0 2 2 2 2 2 2 2 ) ///
	labels("mean dependent variable" "N.obs" "R-Sq" "p1" "p2" "p3" "p4" "p5" "p6" "p7" "p8" "p9")) replace


********
*Columns (6) - (8)

use "$data/admin_data_loans", clear 

********
*Initial data steps
gen log_amount_new = log_amount
replace log_amount_new = log(1) if log_amount_new == .
ren d_uptake_during_after_LL_new d_f
gen A_EDT_elig=(A_EDT==1 & d_lleligible==1)
gen A_EDT_no_elig=(A_EDT==1 & d_lleligible==0)
gen nobt_ne_nolw = EDT_treat==0 & d_lleligible==0 & L_ttreat==0
gen A_EDT_elig_fem=A_EDT_elig*female
gen A_EDT_no_elig_fem=A_EDT_no_elig*female
gen nobt_ne_nolw_fem=nobt_ne_nolw*female

*Note: there are 1857 log amounts but just 1815 at maturity defaults so replacing those
gen at_mat = 1 if at_maturity !=.
replace at_mat = 0 if at_mat ==.
keep if at_mat ==1

est clear
local j =1
foreach y of varlist log_amount_new at_maturity_20 at_maturity  {
	reg `y' EDT_treat	bl_bus_owner female  d_lleligible fu_dummy* if d_f ==1, cl(co_code1)
	estimates store `y'	
	sum `y' if  d_f==1
	sum `y' if d_f==1 & EDT_treat == 0
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}
estout * using "$out/Table7A-col6-8.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(mean_y N r2, fmt(2 0 2 2 2 2 ) ///
	labels("mean dependent variable" "N.obs" "R-Sq")) replace

est clear
local j =1
foreach y of varlist log_amount_new at_maturity_20 at_maturity  {
	reg `y' A_EDT_elig A_EDT_no_elig B_LL C_EDT_LL nobt_ne_nolw ///
		bl_bus_owner female   fu_dummy* if d_f ==1, cl(co_code1)
	estimates store `y'
	test A_EDT_elig =B_LL
	estadd scalar p_diff1 = r(p)
	test A_EDT_elig =C_EDT_LL
	estadd scalar p_diff2 = r(p)
	test C_EDT_LL =B_LL
	estadd scalar p_diff3 = r(p)
	test A_EDT_no_elig =nobt_ne_nolw
	estadd scalar p_diff4 = r(p)
	sum `y' if  d_f==1
	sum `y' if d_f==1 & EDT_treat == 0 & L_ttreat ==0 & d_lleligible==1
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}
estout * using "$out/Table7C-col6-8.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(mean_y N r2 p_diff1 p_diff2 p_diff3 p_diff4, fmt(2 0 2 2 2 2 ) ///
	labels("mean dependent variable" "N.obs" "R-Sq" "p1" "p2" "p3" "p4")) replace

*Female
est clear
local j =1
foreach y of varlist log_amount_new at_maturity_20 at_maturity  {
	reg `y' EDT_treat EDT_female bl_bus_owner female d_lleligible fu_dummy* if  d_f==1 , cl(co_code1)
	estimates store `y'
	test EDT_treat + EDT_female=0
	estadd scalar p_diff1 = r(p)
	sum `y' if d_f==1
	sum `y' if  d_f==1 & EDT_treat == 0 & female==0
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}
estout * using "$out/Table7B-col6-8.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(mean_y N r2 p_diff1, fmt(2 0 2 2 2 2 2 2 2 ) ///
	labels("mean dependent variable" "N.obs" "R-Sq" "p1")) replace

est clear
local j =1
foreach y of varlist log_amount_new at_maturity_20 at_maturity  {
	reg `y' A_EDT_elig A_EDT_elig_fem A_EDT_no_elig A_EDT_no_elig_fem ///
		nobt_ne_nolw  nobt_ne_nolw_fem B_LL B_female C_EDT_LL C_female ///
		bl_bus_owner female fu_dummy* if  d_f==1 , cl(co_code1)
	estimates store `y'
	test A_EDT_elig =B_LL
	estadd scalar p_diff1 = r(p)
	test A_EDT_elig =C_EDT_LL
	estadd scalar p_diff2 = r(p)
	test C_EDT_LL =B_LL
	estadd scalar p_diff3 = r(p)
	test A_EDT_no_elig =nobt_ne_nolw
	estadd scalar p_diff4 = r(p)
	test A_EDT_elig + A_EDT_elig_fem=0
	estadd scalar p_diff5 = r(p)
	test A_EDT_no_elig + A_EDT_no_elig_fem=0
	estadd scalar p_diff6 = r(p)
	test nobt_ne_nolw + nobt_ne_nolw_fem=0
	estadd scalar p_diff7= r(p)
	test B_LL +B_female =0
	estadd scalar p_diff8 = r(p)
	test C_EDT_LL +C_female =0
	estadd scalar p_diff9 = r(p)
	sum `y' if d_f==1
	sum `y' if  d_f==1 & EDT_treat == 0 & L_ttreat ==0 & d_lleligible==1 & female==0
	estadd scalar mean_y=r(mean)
	local j = `j'+1
}

estout * using "$out/Table7D-col-6-8.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(mean_y N r2 p_diff1 p_diff2 p_diff3 p_diff4 p_diff5 p_diff6 p_diff7 p_diff8 p_diff9, fmt(2 0 2 2 2 2 2 2 2 ) ///
	labels("mean dependent variable" "N.obs" "R-Sq" "p1" "p2" "p3" "p4" "p5" "p6" "p7" "p8" "p9")) replace
